package com.ciaojian.store.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ciaojian.core.util.Result;
import com.ciaojian.store.service.OrderCommissionServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author oxiny
 */
@Slf4j
@Api(tags = "订单提成")
@RestController
@RequestMapping("/order/commission")
public class OrderCommissionController {
    @Resource
    private OrderCommissionServiceImpl orderCommissionService;

    @ApiModelProperty("发型师提成排名")
    @GetMapping("/rank")
    public Result getRank(Integer storeId,
                          @DateTimeFormat(pattern = "yyyy-MM") Date date,
                          @RequestParam(defaultValue = "0") Integer pageNo,
                          @RequestParam(defaultValue = "6") Integer pageSize) {
        return Result.ok(orderCommissionService.getBaseMapper().calculateRank(new Page<>(pageNo, pageSize), storeId, date));
    }
}
